// stores/captainOprate.js
import { defineStore } from 'pinia'

export const captainOprate = defineStore('captainOprate', {
    state: () => ({
        isActive:true,
        activeName:"1",
        activeName_sub_1: "1",
        account:{},
        creatOrderOperation:{
            size:0,
            type:"",
            tif:"",
            price: 0
        },
        options:[
            {
              value: 'gtc',
              label: 'gtc-一直有效，直到取消',
            },
            {
              value: 'ioc',
              label: 'ioc-立即成交或者取消，只吃单不挂单',
            },
            {
              value: 'poc',
              label: 'poc-被动委托，只挂单不吃单',
            },
            {
              value: 'fok',
              label: 'fok-完全成交，或者完全取消',
            }
          ]
    }),
    actions: {
        updatedActive(template){
            this.isActive=template
        },
        updatedActiveName(activeName) {
            this.activeName = activeName
            this.clearInterval()
        },
        updatedActiveNameSub1(activeName) {
            this.activeName_sub_1 = activeName
            this.clearInterval()
        },
        updatedaccount(account) {
            this.account = account
        },
        updatedaOrderSize(size) {
            this.creatOrderOperation.size = size
        },
        updatedaOrderType(type) {
            this.creatOrderOperation.type = type
        },
        clearInterval(){
            console.log('触发')
            this.creatOrderOperation.price=0
            this.creatOrderOperation.size=0
            this.creatOrderOperation.tif='ioc'
            this.creatOrderOperation.price = ''
        }
    }
});
